package com.spzx.cart.api.factory;

import com.spzx.cart.api.RemoteCartService;
import com.spzx.cart.domain.CartItem;
import com.spzx.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.rmi.Remote;
import java.util.List;

@Component
public class RemoteCartFallbackFactory  implements FallbackFactory<RemoteCartService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteCartFallbackFactory.class);


    @Override
    public RemoteCartService create(Throwable cause) {
        return new RemoteCartService() {
            @Override
            public R<List<CartItem>> listCheckedCartItems(Long userId) {
                return R.fail("获取选中的购物项列表失败"+cause.getMessage());
            }
        };
    }
}
